--编写者：alt
--功能介绍：真伤
--使用方法：直接粘贴 修改herta_reallydamage herta_takingreallydamage

--真伤
local Health = require "components/health"
local oldDoDelta = Health.DoDelta
function Health:DoDelta(amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb, ...)
    if afflicter and afflicter.herta_reallydamage then
        ignore_invincible = true
        ignore_absorb = true
    end
    return oldDoDelta(self, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb, ...)
end

local SpDamageUtil = require("components/spdamageutil")
local oldApplySpDefense = SpDamageUtil.ApplySpDefense
SpDamageUtil.ApplySpDefense = function(ent, tbl, ...)
    if ent and ent.herta_takingreallydamage then
        return tbl
    end

    return oldApplySpDefense(ent, tbl, ...)
end
local PlanarEntity = require("components/planarentity")
local oldAbsorbDamage = PlanarEntity.AbsorbDamage
function PlanarEntity:AbsorbDamage(damage, attacker, weapon, spdmg, ...)
    if attacker and attacker.herta_reallydamage then
        return damage, spdmg
    end
    return oldAbsorbDamage(self, damage, attacker, weapon, spdmg, ...)
end

local DamageTypeResist = require("components/damagetyperesist")
local oldGetResist = DamageTypeResist.GetResist
function DamageTypeResist:GetResist(attacker, weapon, ...)
    if attacker and attacker.herta_reallydamage then
        return 1
    end
    return oldGetResist(self, attacker, weapon, ...)
end

--saddler:ApplyDamage
local Saddler = require("components/saddler")
local oldApplyDamage = Saddler.ApplyDamage
function Saddler:ApplyDamage(damage, attacker, weapon, spdamage, ...)
    if attacker and attacker.herta_reallydamage then
        return damage, spdamage
    end
    return oldApplyDamage(self, damage, attacker, weapon, spdamage, ...)
end

local Inventory = require("components/inventory")
local oldInventoryApplyDamage = Inventory.ApplyDamage
function Inventory:ApplyDamage(damage, attacker, weapon, spdamage, ...)
    if attacker and attacker.herta_reallydamage then
        return damage, spdamage
    end
    return oldInventoryApplyDamage(self, damage, attacker, weapon, spdamage, ...)
end
